﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Log
{
    internal class Queues : List<IQueueInfo>, IList<IQueueInfo>
    {
        /// <summary>
        /// 创建新对象
        /// </summary>
        /// <returns></returns>
        public IQueueInfo New()
        {
            IQueueInfo myQueue = new QueueInfo();
            this.Add(myQueue);
            return myQueue;
        }
        /// <summary>
        /// 判断队列是否存在
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        public bool Exists(string Name)
        {
            foreach (var item in this)
            {
                if (item.Name == Name)
                    return true;
            }
            return false;
        }
        /// <summary>
        /// 获取队列信息
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        public IQueueInfo GetQueue(string Name)
        {
            return this.Find(q => q.Name == Name);
        }
        public IList<IQueueInfo> GetQueues()
        {
            return this.FindAll(q => q.Status == QueueStatus.Close);
        }
    }
}
